package com.eco.fanliapp.admin.controller.web;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eco.fanliapp.admin.annotation.SysLogAnnotation;
import com.eco.fanliapp.admin.common.BaseController;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.AppUser;
import com.eco.fanliapp.service.IAppUserService;
import com.eco.fanliapp.service.ISyUserMoneyLogService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 账户余额日志 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-10-21
 */
@RestController
@RequestMapping("/web/syUserMoneyLog")
public class SyUserMoneyLogController extends BaseController {

	@Autowired
	private IAppUserService appUserService ;
	@Autowired
	private ISyUserMoneyLogService syUserMoneyLogService ;
	/**
	 * 账户日志列表
	 * @param currentPage
	 * @param pageSize
	 * @param searchKey
	 * @param logType
	 * @return
	 */
	@GetMapping("/findList")
	@SysLogAnnotation(value = "查看了用户余额日志",userType = 2)
	public ServerResponse findList(@RequestParam(defaultValue = "1") Integer currentPage , @RequestParam(defaultValue = "10") Integer pageSize,String searchKey,Integer logType){
		Long userId = null;

		//判断是否启用了(id，name,weChatName)条件搜索
//		if(StringUtils.isNotEmpty(searchKey)){
//			QueryWrapper<AppUser> userQuery = new QueryWrapper<>();
//			userQuery.and(wrapper -> wrapper.eq("user_id",searchKey).or().like("user_name",searchKey).or().like("weChat_nickname",searchKey));
//			List<AppUser> list = appUserService.list(userQuery);
//			if(CollectionUtils.isNotEmpty(list)){
//				userId = list.get(0).getUserId();
//			}else{
//				return ServerResponse.createByErrorMessage("该用户不存在");
//			}
//		}

		return syUserMoneyLogService.selectUserMoneyLogs(currentPage,pageSize,searchKey,logType);

	}


}
